<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Newsapi extends Model
{
    protected $table ='news';
    public $timestamps = false;
    protected $guarded = [
        'title', 'img', 'redirect_url', 'sort', 'on_line_time', 'off_line_time', 'created_at', 'updated_at'
    ];

    public function getData($id=[]){
        $newsList = array();
        $sql = \DB::table($this->table)
            ->whereNull('deleted_at')
            ->whereNotNull('article');
        if(!empty($id)){
            $sql=$sql->where('id',$id);
        }
        $newsList['list'] = $sql->select('id','title','backgroundImage','created_at','article')->orderBy('created_at', 'desc')

            ->get();

        return $newsList;
    }


}